package koyi.android.learningproject.fragments;

import koyi.android.learningproject.R;
import android.content.Context;
import android.content.res.TypedArray;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

public class AnimalFragment extends Fragment{
	private static final String ARG_ID = "AnimalFragment:id";
    private static TypedArray mImageDrawables;
    private ImageView mImage;

    public static Fragment newInstance(int id) {

        Bundle args = new Bundle();
        args.putInt(ARG_ID, id);

        Fragment fragment = new AnimalFragment();
        fragment.setArguments(args);

        return fragment;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

        View view = inflater.inflate(R.layout.fragment_animal, container, false);
        mImage = (ImageView) view.findViewById(R.id.animalImage);

        final Bundle args = getArguments();

        if (args != null) {
        	if(args.getInt(ARG_ID) == 0) {
        		mImage.setImageResource(R.drawable.leon);
        	}else {
        		mImage.setImageResource(R.drawable.tigre);
        	}
            
        }

        return view;
    }
}
